﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MMITDomain.Abstract;
using MMITDomain.Entities;

namespace MMITDomain.Concrete
{
    public class EFAccountTypeRepository : IAccountTypeRepository
    {
        EFDbContext dbContext = new EFDbContext();

        #region IAccountTypeRepository Members

        public IQueryable<Entities.AccountType> AccountTypes
        {
            get 
            { 
                return dbContext.AccountTypes; 
            }
        }

        public void SaveAccountType(AccountType ObjAccountType)
        {
            if (ObjAccountType.Id == 0)
            {
                dbContext.AccountTypes.Add(ObjAccountType);
            }

            dbContext.SaveChanges();
        }

        public void DeleteAccountType(AccountType ObjAccountType)
        {
            dbContext.AccountTypes.Remove(ObjAccountType);
            dbContext.SaveChanges();
        }

        public AccountType GetAccountTypeById(int iAccountTypeId)
        {
            return dbContext.AccountTypes.Find(iAccountTypeId);
        }
        #endregion
    }
}
